package com.bilgeadam.hibernate.program;

import java.io.Serializable;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * 
 * @author Bora SAYINER
 * @since Nov 15, 2014 5:13:42 PM
 * @version 1.0.0
 */
@Entity
@Table(name = "VEHICLES")
public class Vehicle implements Serializable {

	private long id;
	private String brand;
	private String model;
	private Employee employee;

	@Id
	@GeneratedValue
	@Access(AccessType.FIELD)
	@Column(name = "VEHICLE_ID")
	public long getId() {
		return id;
	}

	@Column(name = "BRAND_NAME")
	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	@Column(name = "MODEL_NAME")
	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	@OneToOne(mappedBy = "vehicle")
	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) return true;
		if (obj == null) return false;
		if (getClass() != obj.getClass()) return false;
		Vehicle other = (Vehicle) obj;
		if (id != other.id) return false;
		return true;
	}

	@Override
	public String toString() {
		return "Vehicle [id=" + id + ", brand=" + brand + ", model=" + model + "]";
	}

}
